from django.db import models

# Create your models here.

# models.py
from django.db import models

class ClassroomMember(models.Model):
    classroomId = models.IntegerField(default=0)
    userId = models.IntegerField(default=0)
    orderId = models.IntegerField(default=0)
    levelId = models.IntegerField(default=0)
    noteNum = models.IntegerField(default=0)
    threadNum = models.IntegerField(default=0)
    locked = models.BooleanField(default=False)
    role = models.CharField(max_length=255, default='auditor')
    createdTime = models.IntegerField(default=0)
    lastLearnTime = models.IntegerField(null=True)
    learnedNum = models.IntegerField(null=True)
    updatedTime = models.IntegerField(default=0)
    deadline = models.IntegerField(default=0)
    refundDeadline = models.IntegerField(default=0)
    deadlineNotified = models.IntegerField(default=0)
    class Meta:
        db_table = 'classroom_member'  # 指定表名

#学习日志表
class ActivityLearnLog(models.Model):
    id = models.AutoField(primary_key=True)  # 主键，自动递增
    activityId = models.IntegerField(default=0)  # 教学活动ID
    courseTaskId = models.IntegerField(default=0)  # 课程任务ID
    userId = models.IntegerField(default=0)  # 用户ID
    mediaType = models.CharField(max_length=32, default='0')  # 活动类型
    event = models.CharField(max_length=32, default='0')  # 事件类型
    data = models.TextField()  # 学习行为数据
    learnedTime = models.IntegerField(default=0)  # 用时时长
    createdTime = models.IntegerField(default=0)  # 创建时间

    class Meta:
        db_table = 'activity_learn_log'  # 指定数据库表名

#观看时长
class UserCourseTaskWatchingTime(models.Model):
    userId = models.IntegerField()
    courseTaskId = models.IntegerField()
    watchingTime = models.CharField(max_length=255)  # 假设 watchingTime 是字符串格式

    class Meta:
        unique_together = (('userId', 'courseTaskId'),)
        db_table = 'watch_time'

    def __str__(self):
        return f"User {self.userId} - Course Task {self.courseTaskId} - Watching Time {self.watchingTime}"
#学生分数-等级
class StudentScore(models.Model):
    userId = models.IntegerField()
    courseTaskId = models.IntegerField()
    score = models.IntegerField()

    class Meta:
        db_table = 'student_score'  # 指定模型对应的数据库表名
        unique_together = (('userId', 'courseTaskId'),)

    def __str__(self):
        return f"{self.userId} - {self.courseTaskId} - {self.score}"